package com.objetdirect.gwt.umldrawer.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.HistoryListener;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

@SuppressWarnings("deprecation")
public class OProDesUML implements EntryPoint, HistoryListener {

	private VerticalPanel mainPanel = new VerticalPanel();

	public void onModuleLoad() {

		if (History.getToken().length() == 0 || History.getToken() == null) {
			History.newItem("Home");
		}
		
		History.addHistoryListener(this);
		History.onHistoryChanged(History.getToken());
		
		RootPanel.get().add(mainPanel);
	}

	@Override
	public void onHistoryChanged(String historyToken) {

		mainPanel.clear();
		mainPanel.setStyleName("myProgram");
		if (historyToken.equals("Home") || historyToken.equals("")) {
			mainPanel.add(new HomePage().getPageContent());
		} else if (historyToken.equals("SignIn")) {
			mainPanel.add(new SignInPage().getPageContent());
		} else if (historyToken.equals("SignUp")) {
			mainPanel.add(new SignUpPage().getPageContent());
		} else if (historyToken.equals("AboutUs")) {
			mainPanel.add(new AboutUsPage().getPageContent());
		} else if (historyToken.equals("Tutorials")) {
			mainPanel.add(new TutorialsPage().getPageContent());
		} else if (historyToken.equals("Samples")) {
			mainPanel.add(new SamplesPage().getPageContent());
		} else if (historyToken.equals("TermsOfUse")) {
			mainPanel.add(new TermsOfUsePage().getPageContent());
		} else if (historyToken.equals("WorkSpace")) {
			mainPanel.add(new WorkSpacePage().getPageContent());
		} else if (historyToken.equals("UMLDrawer")) {
			mainPanel.setStyleName("UMLDrawer");
			mainPanel.add(new UMLDrawer().getUMLDrawerPage());
		}
	}
}
